<template>
	<div>
		<NavigationBar title-text="科室详情" />
		<Message ref="message" />
		<Loading ref="loading" fullscreen />

		<div class="server-detail-container w-full pt-160rpx pb-0rpx px-0rpx bg-hex-a0cfff overflow-x-hidden">
			<div class="w-full min-h-90vh flex-column bg-white overflow-x-hidden">
				<div class="w-full h-400rpx">
					<image class="w-full h-full" :src="departmentinfo.img" mode="aspectFill" />
				</div>
				<div class="w-full">
					<div class="bor w-full mt-20rpx pb-20rpx pl-30rpx text-30rpx">上门编号：{{ departmentinfo.id }}</div>
					<div class="bor w-full mt-20rpx pb-20rpx pl-30rpx text-30rpx">科室名称：{{ departmentinfo.name }}</div>
					<div class="bor w-full mt-20rpx pb-20rpx pl-30rpx text-30rpx">科室分类：{{ departmentinfo.classify }}</div>
					<div class="bor w-full mt-20rpx pb-20rpx pl-30rpx text-30rpx">医生工号：{{ departmentinfo.jobnumber }}</div>
					<div class="bor w-full mt-20rpx pb-20rpx pl-30rpx text-30rpx">医生姓名：{{ departmentinfo.userName }}</div>
				</div>
				<div class="foot w-full flex items-center justify-center pb-50rpx mt-50rpx">
					<u-button type="primary" shape="circle" size="medium" @click="gotoDetail">挂号问诊</u-button>
				</div>
			</div>
		</div>
	</div>
</template>

<script setup lang="ts">
import Message from '@/components/message/src/message.vue';
import type { MessageMethod } from '@/components/message';
import Loading from '@/components/loading/src/loading.vue';
import type { LoadingMethod } from '@/components/loading';
import NavigationBar from '@/components/navigation-bar/src/navigation-bar.vue';
import { gotoPage } from '@/common/utils';
import { useUserStore } from '@/store';
import { userApi, serveApi } from '@/service/api';

const userStore = useUserStore();

const message = ref<InstanceType<typeof Message> & MessageMethod>(null);
const loading = ref<InstanceType<typeof Loading> & LoadingMethod>(null);
const classify = ref<string>('');
const jobnumber = ref<string>('');
const role = ref<string>('');
const departmentinfo = ref({});
// 初始化
const init = async () => {
	const res = await serveApi.getDepartmentInfo({ jobnumber: jobnumber.value, classify: classify.value });
	console.log(res.data?.result[0]);
	departmentinfo.value = res.data?.result[0];
};
// 跳转预约页面
const gotoDetail = useThrottleFn(
	(): void => {
		gotoPage(`/pages/interrogation/interrogation?jobnumber=${jobnumber.value}&classify=${classify.value}`);
	},
	2000,
	false,
	true
);

// 返回上一页
const handleNavigateBack = (): void => {
	uni.navigateBack({
		delta: 2,
	});
};
onLoad((option) => {
	if (option) {
		classify.value = option.classify;
		jobnumber.value = option.jobnumber;
		console.log(classify.value);
		init();
		return;
	}
	nextTick(() => uni.navigateBack());
});
onShow(() => {});
</script>

<style scoped lang="scss">
@import 'depart-info';
</style>
